<template>
    <el-dialog title="选择合约除外责任条件" :visible.sync="dialogVisible" size="small" :close-on-click-modal="false" :close-on-press-escape="false" :before-close="off">
        <el-form label-width="150px" >
        <el-row :span="24">
          <el-form-item label="" label-width="150px" :span="24">
          <el-select v-model="fhexitemkindCodes" multiple  placeholder="请选择" filterable value-key="itemkind"  size="small" style="width:80%">
            <el-option v-for="item in fhexitemkindOptions" :key="item.itemkind" :label="item.itemkind + '-'+ item.itemkinddesc"
                       :value="item"></el-option>
          </el-select>
        </el-form-item>
        </el-row>
      </el-form>
        <span slot="footer" class="dialog-footer">
           <el-button @click="off">取 消</el-button>
           <el-button type="danger" @click="clear">清 空</el-button>
           <el-button type="success" @click="select">确 定</el-button>
        </span>
    </el-dialog>
</template>

<script>

  import RiskAPI from "../../../../js/production/risk/riskAPI"

  export default {
	data() {
		return {
			dialogVisible: true,
      formData: {
        fhtreaty:'',
        fhsection:'',
      },
			fhexitemkindCodes: [],
      fhexitemkindOptions: [],
      tmpFhindex: '',
		}
	},
	mounted() {
    this.tmpFhindex = this.$parent.tmpFhindex;
    this.formData.fhtreaty = this.$parent.formData.fhData[this.tmpFhindex].fhtreaty;
    this.formData.fhsection = this.$parent.formData.fhData[this.tmpFhindex].fhsection;
    RiskAPI.initFhexitemkindOptions(this);
    this.fhexitemkindCodes = this.$parent.formData.fhData[this.tmpFhindex].fhexitemkindArray;
	},
	methods: {
		select() {
			this.$parent.formData.fhData[this.tmpFhindex].fhexitemkind = '';
      this.$parent.formData.fhData[this.tmpFhindex].fhexitemkindArray = [];
			for(let i = 0; i <this.fhexitemkindCodes.length - 1; i++) {
				this.$parent.formData.fhData[this.tmpFhindex].fhexitemkind += this.fhexitemkindCodes[i].itemkind + ",";
			}
			if(this.fhexitemkindCodes.length > 0) {
				this.$parent.formData.fhData[this.tmpFhindex].fhexitemkind += this.fhexitemkindCodes[this.fhexitemkindCodes.length - 1].itemkind;
			}
      this.$parent.formData.fhData[this.tmpFhindex].fhexitemkindArray = this.fhexitemkindCodes;
			this.off();
		},
		clear() {
			this.fhexitemkindCodes = [];
      this.$parent.formData.fhData[this.tmpFhindex].fhexitemkind = '';
			this.$parent.formData.fhData[this.tmpFhindex].fhexitemkindArray = [];
			this.off();
		},
		off() {
			this.$parent.showFhexitemkindDialog = false;
		}
	}
  }
</script>
